using UnityEngine;

public class PlayerInputController : MonoBehaviour
{
	private FPSController fpsControl;

	private void Update()
	{
		if (UnitZ.IsMobile)
		{
			return;
		}
		if (UnitZ.gameManager.IsPlaying)
		{
			if (UnityEngine.Input.GetKeyDown(KeyCode.Escape))
			{
				UnitZ.Hud.TogglePanelByName("InGameMenu");
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.N))
			{
				UnitZ.Hud.TogglePanelByName("Scoreboard");
			}
		}
		if (!(UnitZ.playerManager != null) || !(UnitZ.playerManager.PlayingCharacter != null))
		{
			return;
		}
		FPSController component = UnitZ.playerManager.PlayingCharacter.GetComponent<FPSController>();
		if (UnitZ.playerManager.PlayingCharacter.isLocalPlayer && component != null)
		{
			component.MoveCommand(new Vector3(UnityEngine.Input.GetAxis("Horizontal"), 0f, UnityEngine.Input.GetAxis("Vertical")), Input.GetButton("Jump"));
			if (UnityEngine.Input.GetKeyDown(KeyCode.C))
			{
				component.Sit();
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.F))
			{
				component.OutVehicle();
			}
			component.Sprint(UnityEngine.Input.GetKey(KeyCode.LeftShift));
			if (MouseLock.MouseLocked)
			{
				component.Aim(new Vector2(UnityEngine.Input.GetAxis("Mouse X"), UnityEngine.Input.GetAxis("Mouse Y")));
				component.Trigger1(Input.GetButton("Fire1"));
				component.Trigger2(Input.GetButtonDown("Fire2"));
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.F))
			{
				component.Interactive();
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.V))
			{
				component.SwithView();
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.B))
			{
				component.SwithSideView();
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.R))
			{
				component.Reload();
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.Tab))
			{
				UnitZ.Hud.TogglePanelByName("Inventory");
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.E))
			{
				UnitZ.Hud.TogglePanelByName("Craft");
			}
			if (UnityEngine.Input.GetKeyDown(KeyCode.M))
			{
				UnitZ.Hud.TogglePanelByName("Map");
			}
			component.Checking();
		}
	}
}
